<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增员工管理')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-employee-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工姓名：</label>
                <div class="col-sm-8">
                    <input name="employeeName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工性别：</label>
                <div class="col-sm-8">
                    <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工年龄：</label>
                <div class="col-sm-8">
                    <input name="age" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">部门名称：</label>
                <div class="col-sm-8">
<!--                    <input name="dept" class="form-control" type="text" required>-->
                    <select id="dept" class="form-control select2-selection--single">
                        <option th:each="dept:${depts}" th:value="${dept.deptName}" th:text="${dept.deptName}" th:disabled="${dept.status == '1'}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">是否实习：</label>
                <div class="col-sm-8">
                    <input name="isTrainee" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工岗位：</label>
                <div class="col-sm-8">
<!--                    <input name="post" class="form-control" type="text" required>-->
                    <select id="post" class="form-control select2-selection--single">
                        <option th:each="post:${posts}" th:value="${post.postName}" th:text="${post.postName}" th:disabled="${post.status == '1'}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工手机：</label>
                <div class="col-sm-8">
                    <input name="phone" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <p class="form-control-static"><h5>请为新入职员工填写基本工资表：</h5></p>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">基本工资：</label>
                <div class="col-sm-8">
                    <input name="baseSalary" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">五险一金：</label>
                <div class="col-sm-8">
                    <input name="insurance" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/employee"
        $("#form-employee-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-employee-add').serializeArray();
                var postName = $.form.selectSelects("post");
                var deptName = $.form.selectSelects("dept");
                data.push({"name": "post", "value": postName});
                data.push({"name": "dept", "value": deptName});
                $.operate.save(prefix + "/add", data);
            }
        }

        $(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
        $(function() {
            $('#dept').select2({
                placeholder: "请选择部门",
                allowClear: true
            });
        })




        // $(document).ready(function () {
        //     // 单图上传
        //     $("#singleFile").fileinput({
        //         uploadUrl: ctx + '',
        //         maxFileCount: 1,
        //         autoReplace: true
        //     }).on('fileuploaded', function (event, data, previewId, index) {
        //         var rsp = data.response;
        //         log.info("return url：" + rsp.url)
        //         log.info("reutrn fileName：" + rsp.fileName)
        //         log.info("reutrn newFileName：" + rsp.newFileName)
        //         log.info("return originalFilename：" + rsp.originalFilename)
        //     }).on('fileremoved', function (event, id, index) {
        //         $("input[name='" + event.currentTarget.id + "']").val('')
        //     })
        // });
    </script>
</body>
</html>